/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nc.kyiv.yellow.sociallibrary.POJO;

import java.util.List;
import java.util.Date;
import java.util.Map;

/**
 *
 * @author My
 */
public class Book {

    private String ISBN;
    private String title;
    private String description;
    private int pageNumber;
    private LibUser user;      //can be null
    private String imageURL;
    private String moderStatus;
    private Date registrationDate;   //automatically generated in DB
    private Date publicationDate;    //automatically generated in DB, can be null
    private List<BookAuthor> authors;
    private List<String> genres;
    private String genre;
    private List<BookRating> rating;   //can be null
    private int sumRating;        //can be null
    private float avgRating;      //can be null
    private int currentUserScore;
    private String temporaryAuthors;
    private String temporaryUserID;
    
    //constructor for saving book in DB
    public Book(String ISBN, String title, String description, int pageNumber, 
            String imageURL, String moderStatus, List<BookAuthor> authors, 
            List<String> genres) {
        this.ISBN = ISBN;
        this.title = title;
        this.description = description;
        this.pageNumber = pageNumber;
        this.imageURL = imageURL;
        this.moderStatus = moderStatus;
        this.authors = authors;
        this.genres = genres;
        this.user = null;
        this.registrationDate = null;
        this.publicationDate = null;
        this.rating = null;
    }

    public String getGenre() {
        return genre;
    }
    
    
    
    public String getTemporaryAuthors() {
        return temporaryAuthors;
    }

    public void setTemporaryAuthors(String temporaryAuthors) {
        this.temporaryAuthors = temporaryAuthors;
    }

    public String getTemporaryUserID() {
        return temporaryUserID;
    }

    public void setTemporaryUserID(String temporaryUserID) {
        this.temporaryUserID = temporaryUserID;
    }
    
    //default constructor 
    public Book() {
    }
    
    //constructor for getting book by isbn
    public Book(String ISBN, String title, String description, int pageNumber, 
            String imageURL) {
        this.ISBN = ISBN;
        this.title = title;
        this.description = description;
        this.pageNumber = pageNumber;
        this.imageURL = imageURL;
        this.moderStatus = null;
        this.authors = null;
        this.genres = null;
        this.genre = null;
        this.user = null;
        this.registrationDate = null;
        this.publicationDate = null;
        this.rating = null;
    }
        

    //constructor for saving book in DB
    public Book(Map bookInfo, String[] mapKeys) {
        this.ISBN = bookInfo.get(mapKeys[0]).toString();
        this.title = bookInfo.get(mapKeys[1]).toString();
        this.temporaryAuthors = bookInfo.get(mapKeys[2]).toString();
        System.out.println(temporaryAuthors);
        this.description = bookInfo.get(mapKeys[3]).toString();
        this.pageNumber = Integer.parseInt(bookInfo.get(mapKeys[4]).toString());
        this.imageURL = bookInfo.get(mapKeys[5]).toString();
        this.genre = bookInfo.get(mapKeys[6]).toString();
        if (bookInfo.get(mapKeys[7]) != null) {
            this.temporaryUserID = bookInfo.get(mapKeys[7]).toString();
        } else {
            this.temporaryUserID = null;
        }
        
    }

    public String getISBN() {
        return ISBN;
    }

    public void setISBN(String ISBN) {
        this.ISBN = ISBN;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public LibUser getUser() {
        return user;
    }

    public void setUser(LibUser user) {
        this.user = user;
    }

    public String getImageURL() {
        return imageURL;
    }

    public void setImageURL(String imageURL) {
        this.imageURL = imageURL;
    }

    public String getModerStatus() {
        return moderStatus;
    }

    public void setModerStatus(String moderStatus) {
        this.moderStatus = moderStatus;
    }

    public Date getRegistrationDate() {
        return registrationDate;
    }

    public void setRegistrationDate(Date registrationDate) {
        this.registrationDate = registrationDate;
    }

    public Date getPublicationDate() {
        return publicationDate;
    }

    public void setPublicationDate(Date publicationDate) {
        this.publicationDate = publicationDate;
    }

    public List<BookAuthor> getAuthors() {
        return authors;
    }

    public void setAuthors(List<BookAuthor> authors) {
        this.authors = authors;
    }

    public List<String> getGenres() {
        return genres;
    }

    public void setGenres(List<String> genres) {
        this.genres = genres;
    }

    public List<BookRating> getRating() {
        return rating;
    }

    public void setRating(List<BookRating> rating) {
        this.rating = rating;
    }

    public int getSumRating() {
        return sumRating;
    }

    public void setSumRating(int sumRating) {
        this.sumRating = sumRating;
    }

    public float getAvgRating() {
        return avgRating;
    }

    public void setAvgRating(float avgRating) {
        this.avgRating = avgRating;
    }

    public int getCurrentUserScore() {
        return currentUserScore;
    }

    public void setCurrentUserScore(int currentUserScore) {
        this.currentUserScore = currentUserScore;
    }
}
